<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath %>">
<title>订单管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%-- 引用layui.css --%>
<link rel="stylesheet" type="text/css" href="<%=basePath %>js/layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath %>css/common.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath %>css/laydate.css" />
<script type="text/javascript" src="<%=basePath%>js/laydate.js"></script>
</head>
<body>
	<div class="ibox">
		<div class="ibox-content bodycss">
			<!-- 表单搜索 开始 -->
		 	<section class="panel panel-padding ">
			<form class="layui-form layui-form-pane form-search"
				onsubmit="return false" method="get">
				<div class="layui-form-item layui-inline">
					<label class="layui-form-label">商品名称</label>
					<div class="layui-input-inline">
						<input name="goods_name" id="goods_name"placeholder="请输入商品名称"
							class="layui-input">
					</div>
				</div>	
				<div class="layui-form-item layui-inline">
					<label class="layui-form-label">盘点人姓名</label>
					<div class="layui-input-inline">
						<input name="inventory_name" id="inventory_name" placeholder="请输入盘点人姓名"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-inline">
					<label class="layui-form-label">盘点时间</label>
					<div class="layui-input-inline">
						<input name="inventory_before" id="inventory_before" placeholder="请盘点选择时间"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-inline">
					<label class="layui-form-label">至</label>
					<div class="layui-input-inline">
						<input name="inventory_after" id="inventory_after" placeholder="请选择盘点时间"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item layui-inline">
					<label class="layui-form-label">商品属性</label>
					<div class="layui-input-inline" >
					  <div  style="width:150px">
						<select name="goods_type" id="goods_type" > <!-- 订单状态：0:已取消;10(默认):待确认;20:已确认;30:已配货;40:已发货;50:已收款;60:已退货 -->
							<option value="">请选择</option>
							<option value="0">正品</option>
							<option value="1">打折</option>
							<option value="2">打包</option>
							<option value="3">体验</option>
						</select>
                      </div>
					</div>
				</div>
				<div class="layui-form-item layui-inline">
					<button class="layui-btn layui-btn-primary" lay-submit lay-filter="seach">
						<i class="layui-icon"></i> 搜 索
					</button>
				</div>
			</form>
			</section>
			<!-- 表单搜索 结束 -->
			<section class="panel panel-padding ">
				<div class="ibox-toolbar">
					<button id="exportExcellButton" data-title="导出Excel"class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe667;</i> 导出Excel方式一</button>	
					<button class="layui-btn layui-btn-sm" id="getCheckData" >导出Excel方式二</button>
				</div>
			<table class="layui-table"
				lay-data="{
	                        id: 'menuTeble',
	                        width:'auto',
	                        url:'${pageContext.request.contextPath}/iinventory/getData.do',
	                        page:true,
	                        even:true,
	                        skin:'row',
	                        limits:[10,20,30,40,50],
	                        limit:10,
							method:'post'                      
	                        }"
				lay-filter="popedomLay" id = "dataTable">
				<!-- 需要将默认的请求的方式改变一下，改为post即可 -->
				<thead>
					<tr>
						<th lay-data="{checkbox:true,disabledKey:'check_status',disabledKeyValue:'1,2'}"></th>
						<th lay-data="{type:'numbers', width:65}">序号</th>
						<th lay-data="{field:'goods_id', width:259,align:'center'}">商品id</th>
						<th lay-data="{field:'goods_name', width:269,align:'center'}">商品名称</th>
						<th lay-data="{field:'goods_num', width:269,align:'center'}">盘点数量</th>
						<th lay-data="{field:'inventory_time', width:269,align:'center'}">盘点时间</th>
						<th lay-data="{field:'inventory_name', width:269,align:'center'}">盘点人</th>
						<th lay-data="{field:'goods_type', width:259,align:'center',templet:'#m_type'}">商品属性</th>
				     </tr>
				</thead>
			</table>
			</section>
		</div>
	</div>
	
	<script type="text/html" id="m_type">	
	    {{#  if(d.goods_type == "0") {  }}
			<font color="#00ff00">正品</font>
		{{#  } else if(d.goods_type == "1") {  }}
			<font color="#ff0000">打折</font>
         {{#  } else if(d.goods_type == "2") {  }}
			<font color="#ff0000">打包</font>
		{{#  } else if(d.goods_type == "3") {  }}
			<font color="#ff0000">体验品</font>
		{{#  }  }}
    </script>
    <script type="text/javascript" src="<%=basePath%>js/layui/layui.js"></script>
	<script type="text/javascript">
	layui.config({ base: "<%=basePath%>/js/common/"}).use(["common", "element", "layer", "form", "table", "jquery"], function(){
			var elem = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			layui.common.init();			
			/**
			 * 监听刷新表格
			 */
			form.on('submit(seach)', function(data){
				// layer.msg(JSON.stringify(data.field));
				table.reload('menuTeble', {
					where: data.field,
				});
				return false;
			});
	    //导出Excel方法一
	    $("#exportExcellButton").on("click",function(){
	       	layer.load(1,{time:1000});
	       	window.location.href = "iinventory/exportOne.do?goods_id="+$("#goods_id").val()+"&goods_name="+$("#goods_name").val()+"&inventory_name="+$("#inventory_name").val()+"&inventory_time="+$("#inventory_time").val();
	    });
	    //导出Excel方法二
	    var active = {
	    	getCheckData: function(){
    		  var checkStatus = table.checkStatus('menuTeble'),
    		  data = checkStatus.data;
	   		     }
		    };
	    $('#getCheckData').on('click', function(){
			 active.getCheckData();
			  var checkStatus = table.checkStatus('menuTeble');
			  var data = checkStatus.data;
			  var nadate = JSON.stringify(data);
			  	window.location.href = "iinventory/exportExcellTwo.do?data="+nadate;//这样从前台传输的数据格式就是json格式的String类型数据
			    console.log(data);
			});
	});
</script>
<script type="text/javascript">
	let start_a = laydate.render({
		elem: '#inventory_before',//指定元素
		trigger: 'click', //采用click弹出
        theme: '#3278F0',
        done: function (value, date, endDate) {
            end.config.min = {
                year: date.year,
                month: date.month - 1,
                date: date.date,
            }; //开始日选好后，重置结束日的最小日期
            end.config.value = {
                year: date.year,
                month: date.month - 1,
                date: date.date,
            }; //将结束日的初始值设定为开始日
        }
	});
	let end = laydate.render({
		elem: '#inventory_after',
		trigger: 'click', //采用click弹出
        theme: '#3278F0',
        done: function (value, date, endDate) {
            start_a.config.max = {
                year: date.year,
                month: date.month - 1,
                date: date.date,
            }; //结束日选好后，重置开始日的最大日期
        }
	});
</script>
</body>
</html>
